package com.feihong.txgw.tx_model;

import com.feihong.txgw.inter.contract.integral.IIntegralContract;
import com.feihong.txgw.model.bean.integral.IntegralBackEntity;
import com.feihong.txgw.utils.cache.AbNetWorkCache;
import com.feihong.txgw.utils.cache.CacheManager;
import com.feihong.txgw.utils.helper.RxHelper;
import com.feihong.txgw.utils.manage.RetrofitManager;

import io.reactivex.Observable;

/**
 * @Author wangziheng
 * @ProjectName txgw_app
 * @ClassName IntegralMainModel
 * @package com.feihong.txgw.tx_model
 * @data 2018/5/3 16:40
 * @Describe
 * @Change
 */
public class IntegralMainModel implements IIntegralContract.IIntegralMainModel {
    public static IntegralMainModel create() {
        return new IntegralMainModel();
    }

    @Override
    public Observable<IntegralBackEntity>  getBackIntegralData(String cacheKey, String requestType, int pageNum) {
          Observable<IntegralBackEntity>  observable = RetrofitManager.getInstance().getIntegralData(requestType, String.valueOf(pageNum)).compose(RxHelper.<IntegralBackEntity> rxSchedulerHelper());
//        if (pageNum == 1) {
//            AbNetWorkCache<IntegralBackEntity>  abNetWorkCache = new AbNetWorkCache<IntegralBackEntity> () {
//                @Override
//                public Observable<IntegralBackEntity>  get(String key, Class cls) {
//                    return observable;
//                }
//            };
//            return CacheManager.getInstance().load(cacheKey, IntegralBackEntity.class, abNetWorkCache);
//        }else {
            return observable;
//        }
    }
}
